package com.googlecode.monitoring.web.model;

import java.util.Date;


public class DutyScheduleItem implements Comparable<DutyScheduleItem> {
	
	private PersonWithId person;
	private Date startDate;

	public DutyScheduleItem(PersonWithId person, Date startDate) {
		this.person = person;
		this.startDate = startDate;
	}

	public PersonWithId getPerson() {
		return person;
	}

	public Date getStartDate() {
		return startDate;
	}

	@Override
	public int compareTo(DutyScheduleItem o) {
		return startDate.compareTo(o.startDate);
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof DutyScheduleItem)) {
			return false;
		}

		DutyScheduleItem that = (DutyScheduleItem) o;

		if (person != null ? !person.equals(that.person) : that.person != null) {
			return false;
		}
		if (startDate != null ? !startDate.equals(that.startDate) : that.startDate != null) {
			return false;
		}

		return true;
	}

	@Override
	public int hashCode() {
		int result = person != null ? person.hashCode() : 0;
		result = 31 * result + (startDate != null ? startDate.hashCode() : 0);
		return result;
	}

	@Override
	public String toString() {
		return "DutyScheduleItem{" +
			"person=" + person +
			", startDate=" + startDate +
			'}';
	}
}
